package cn.ticket.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.ticket.dao.WorkticketorderMapper;
import cn.ticket.model.Staff;
import cn.ticket.model.Workticketorder;
import cn.ticket.service.WorkTicketOrderService;
@Service
public class WorkTicketOrderServiceImpl implements WorkTicketOrderService {

	@Autowired
	private WorkticketorderMapper workTicketOrderMapper;
	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(Workticketorder record) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.insert(record);
	}

	@Override
	public int insertSelective(Workticketorder record) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.insertSelective(record);
	}

	@Override
	public Workticketorder selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(Workticketorder record) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(Workticketorder record) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.updateByPrimaryKey(record);
	}

	@Override
	public List<Map<String, Object>> getAuditingTicketInfoByDepartmentId(Integer departmentId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getAuditingTicketInfoByDepartmentId(departmentId);
	}

	@Override
	public List<Map<String, Object>> getAuditedTicketInfoByStaffId(Integer auditStaffId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getAuditedTicketInfoByStaffId(auditStaffId);
	}

	@Override
	public List<Map<String, Object>> getValidateTicketInfoByStaffId(Integer staffId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getValidateTicketInfoByStaffId(staffId);
	}

	@Override
	public List<Map<String, Object>> getInvalidateTicketInfoByStaffId(Integer staffId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getInvalidateTicketInfoByStaffId(staffId);
	}

	@Override
	public Boolean AuditTicket(Workticketorder workticketorder, Staff auditStaff) {
		// TODO Auto-generated method stub
		if (workticketorder==null||workticketorder.getAuditstatus()==1) {
			return false;
		}
		workticketorder.setAuditstatus((byte) 1);
		workticketorder.setAuditdate(new Date());
		workticketorder.setAuditstaffid(auditStaff.getId());
		int num=updateByPrimaryKeySelective(workticketorder);
		if (num==1) {
			return true;
		}
		return false;
	}

	@Override
	public List<Map<String, Object>> getAuditedTicketInfoByAuditorId(Integer auditorId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getAuditedTicketInfoByAuditorId(auditorId);
	}

	@Override
	public List<Map<String, Object>> getAuditingTicketInfo() {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getAuditingTicketInfo();
	}

	@Override
	public List<Map<String, Object>> getInfoByBusId(Integer busId) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getInfoByBusId(busId);
	}

	@Override
	public List<Map<String, Object>> getInfoByDepartureDate(Date departureDate) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getInfoByDepartureDate(departureDate);
	}

	@Override
	public List<Map<String, Object>> getInfoByDepartureDateRange(Date startDate, Date endDate) {
		// TODO Auto-generated method stub
		return workTicketOrderMapper.getInfoByDepartureDateRange(startDate, endDate);
	}

}
